mui.init({
});

var vipinfo;
mui.plusReady(function () {
	plus.navigator.setFullscreen(false);
    var api_host = plus.storage.getItem('HOST_URL');
	vipinfo=new Vue({
		el: '#userInfo_list',
		data: {
			vipdetail:[],
			user_detail:'',
			vip_in:'',
			bac_url:'',
			user_vip:'',
			styleObject:'',
			loginSta:0,
		},
		mounted(){
			this.getvip();
			this.updateStatus();
		},
		methods:{
			updateStatus:function(){
				showWatting();
				var api_host = plus.storage.getItem('HOST_URL');
				var self = this;
				mui.ajax({
					url: api_host + '/api/linxuan/user/checkLoginStatus',
					dataType: 'json',
					headers:{'User-Token':plus.storage.getItem('UserToken')},
					timeout:3000,
					type: 'get',
					success: function (msg) {
						if (msg.code == 1) {
							self.loginSta = 1;
							self.user_detail = msg.data;
							self.vip_in=getMemberVipIcon(parseInt(msg.data.vip)-1);
							self.bac_url=getMemberVipBackgroundImages(parseInt(msg.data.vip)-1);
							self.user_vip=parseInt(msg.data.vip);
							self.styleObject= {
								background: getMemberVipBackgroundImages(parseInt(msg.data.vip)-1)
							};
						} else {
							self.loginSta = 0;
							mui.toast(msg.msg, {duration: '300'});
						}
					},
					error: function (xhr, type, errorThrown) {
						mui.toast('登录状态请求失败请重试', {duration: '300'});
					},
					complete:function () {
						plus.nativeUI.closeWaiting();
					}
				});
			},
			getvip:function(){
				var self = this;
				mui.ajax({
					url: api_host + '/api/linxuan/user/getvip',
					dataType: 'json',
					type: 'get',
					headers:{'User-Token':plus.storage.getItem('UserToken')},
					timeout:3000,
					success: function (msg) {
						if (msg.code == 1) {
							self.vipdetail = msg.data;
						} else {
							console.log(msg.msg);
						}
					},
					error: function (xhr, type, errorThrown) {
						mui.toast('请求出错，请重试');
					},
					complete:function () {
						plus.nativeUI.closeWaiting();
					}
				});
			},
			open_li:function (event) {
				//会员等级手风琴
				$(event.currentTarget).find('em').stop(true,true).toggleClass('arr_up');
				$(event.currentTarget).parent('.level_box').find('.level_info').stop(true,true).slideToggle(300);
			},
			//点击价格跳转到订单购买页
			buyVip:function(vip_index,vip,vip_price){
				if(this.loginSta == 0){
					mui.toast('请登录后再试', {duration: '300'});
				}else{
					mui.openWindow({
						url: 'vipOrder.html',
						extras:{'vip_index':vip_index,'vip':vip,'vip_price':vip_price},
						createNew: false,
						show: {
							autoShow: true,
							aniShow: 'pop-in',
							duration: 400
						},
						waiting: {
							autoShow: false,
						}
					})
				}

			}
		}
	})
})
